<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script>
        // 1.求1~100之间所有数的总和和平均值
        var sum = 0;
        var ave = 0;
        for (var i=1; i<=100; i++){
            sum += i;
            ave = sum / i
        }
        console.log("1-100所有整数的和是"+ sum);
        console.log("1-100所有整数的平均值是"+ ave);
        console.log("-----------------------------------------------------------------------")
        // 2.1~100所有偶数的和
        var sum = 0;
        var ave = 0;
        for (var i=1; i<=100; i++){
            if (i%2 == 0)
            sum += i;
        }
        console.log("1~100所有偶数的和"+ sum);
        console.log("-----------------------------------------------------------------------")
        // 3.100以内7的倍数的和
        var sum = 0;
        var ave = 0;
        for (var i=1; i<=100; i++){
            if (i%7 == 0)
            sum += i;
        }
        console.log("100以内7的倍数的和"+ sum);
        console.log("-----------------------------------------------------------------------")
        // 4.使用for循环打印出4行5列的星星,每次只能输出一个
        var row = ''
        for (var i=1;i<=4;i++){
            for (var j=1;j<=5;j++){
                row = row +'☆'
            } 
            console.log(row);
            row = ''
            console.log('\n')
        }
        // 5. 使用for循环打印出三角形的星星
        var row = ''
        for (var i=1; i<=5; i++){
            for (var j=1; j<=i; j++){
                row = row + '★'
            }
            console.log(row)
            console.log('\n')
            row = ''
        }
    </script>
</head>
<body>
    
</body>
</html>